package moni.anyou.com.view.tim;

import android.app.Application;

import com.tencent.imsdk.TIMGroupReceiveMessageOpt;
import com.tencent.imsdk.TIMManager;
import com.tencent.imsdk.TIMOfflinePushListener;
import com.tencent.imsdk.TIMOfflinePushNotification;
import com.tencent.qalsdk.sdk.MsfSdkUtils;
import com.tencent.qcloud.timchat.TimApplication;
import com.tencent.qcloud.timchat.utils.Foreground;
import com.tencent.qcloud.tlslibrary.service.TLSService;
import com.tencent.qcloud.tlslibrary.service.TlsBusiness;

import moni.anyou.com.view.R;
import moni.anyou.com.view.config.AnyouerApplication;

public class TimSdk {
    public static void init(final Application application){


        Foreground.init( application);

        TimApplication.initAppcation(application);
        TlsBusiness.init(application);
        TLSService.getInstance().initTlsSdk(application);

        if(MsfSdkUtils.isMainProcess(application)) {
            TIMManager.getInstance().setOfflinePushListener(new TIMOfflinePushListener() {
                @Override
                public void handleNotification(TIMOfflinePushNotification notification) {
                    if (notification.getGroupReceiveMsgOpt() == TIMGroupReceiveMessageOpt.ReceiveAndNotify){
                        //消息被设置为需要提醒
                        notification.doNotify(application, R.mipmap.ic_launcher);
                    }
                }
            });
        }
    }
}
